/*
 * @(#)DocumentInvitationExpiredJob.java 
 * Copyright (c) 2006 DCIVision Ltd All rights reserved.
 * 
 *  This software is the confidential and proprietary information of DCIVision Ltd 
 *  ("Confidential Information"). You * shall not disclose such Confidential
 *   Information and shall use it only in accordance with the terms of the 
 *   license agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.alert.core;

import java.sql.Connection;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Job;
import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.dcivision.framework.DataSourceFactory;
import com.dcivision.framework.SessionContainer;

/**
 * <p>
 * Class Name: DocumentInvitationExpiredJob
 * </p>
 * 
 * @author Greatwall Shao
 * @company DCIVision Limited
 * @creation date 2006-11-28
 */
public class DocumentInvitationExpiredJob implements Job{


  protected Log log = LogFactory.getLog(this.getClass().getName());
  public void execute(JobExecutionContext context) throws JobExecutionException {

    log.info("start DocumentInvitationExpiredJob");
    JobDataMap dataMap = context.getJobDetail().getJobDataMap();
    Connection conn = null;
    SessionContainer sessionContainer = new SessionContainer();

    try {
      conn = DataSourceFactory.getConnection();

      DocumentInvitationManager documentInvitationManager = new DocumentInvitationManager(sessionContainer,conn);      
      documentInvitationManager.handleInvitationExpired(dataMap.getString("updateAlertTypeID"));
      
    } catch (Exception e) {
      log.error(e, e);
    } finally {
      try { conn.close(); } catch (Exception ignore) {} finally { conn = null; }
    }   
  
  }

}
